package com.job.ctrip; /**
 * @author angzhijin
 * @description
 * @create 2022-11-02 18:55
 */
import java.util.*;
public class Trip1102 {

    public static void main(String[] args) {
        D(args);
    }
    public static void D(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        Set<Long> A = new HashSet<>();
        for (long i = 1; i*i <=a ; i++) {
            if(a%i==0){
                A.add(i);
                if(i != a/i) A.add(a/i);
            }
        }
        Set<Long> B = new HashSet<>();
        for (long i = 1; i*i <=b ; i++) {
            if(b%i==0){
                B.add(i);
                if(i != b/i) B.add(b/i);
            }
        }
        int alen = A.size();
        int blen = B.size();
        A.addAll(B);
        Set<Long> set = new TreeSet<>();
        set.addAll(A);
        set.addAll(B);
        for (long n1:A) {
            for (long n2:B) {
                set.add(n1*n2);
            }
        }

        System.out.println(set);
        System.out.println(set.size());
        StringBuffer sb = new StringBuffer();
        int count = 1;
        for(long n:set){
            System.out.print(n);
            System.out.print(" ");
        }
    }

    public static void C(String[] args) {
        int MOD = 1000000007;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] nums = new long[n];
        long ans = 0;
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextLong();
            ans = (ans + nums[i])%MOD;
        }
        for (int i = 0; i < k; i++) {
            int op = sc.nextInt();
            int x = sc.nextInt();
            for (int j = 0; j < n; j++) {
                if(op ==1 ){
                    nums[j] = (nums[j]+x)%MOD;
                }else if(op ==2){
                    nums[j] = Math.max(nums[j]-x, 0);
                }
            }
            System.out.println(Arrays.toString(nums));
        }
        for (int i = 0; i < n; i++) {
            ans+= nums[i];
        }
        System.out.println(ans);
    }

    public static void B(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long count =0;
        count = ((n-1)/3)*2;
        //if(n%2==0 && n/2%3==0) count--;
        if(n%3==0) count /=2;
        System.out.println(count);
    }

    public static void A(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        if(n<3*k){
            System.out.println(-1);
            return;
        }
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < k; i++) {
            sb.append("you");
        }
        for (int i = 3*k; i < n; i++) {
            sb.append("u");
        }
        System.out.println(sb.toString());
    }
}
